package com.zhiliao.iterator.demo2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Aggregate {
    private List<String> list = new ArrayList<>();

    public void add(String ele) {
        list.add(ele);
    }

    public Iterator getIterator() {
        return new Iterator(list);
    }

    public void setList(List<String> list) {
        this.list = list;
    }

    public static Aggregate build(String ... ele) {
        Aggregate aggregate = new Aggregate();
        List<String> list = new ArrayList<>(Arrays.asList(ele));
        aggregate.setList(list);
        return aggregate;
    }
}
